<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>跟随鼠标的天使</title>
    <style>
        img{
            /* 必须有这个定位不然就不会跟着鼠标走 */
            position: absolute;
            left: 0px;
            top: 0px;
        }
        div{
            position: absolute;
            left: 0px;
            top: 0px;
            width: 100px;
            height: 100px;
            background-color: black;
        }
    </style>
</head>
<body>
    <div>

    </div>
    <img src="./images/tianshi.gif">
    <script>
        //获取元素对象
        let IMG=document.querySelector('img')
        //监听事件
        // document.addEventListener('mousedown',function(e){
            document.addEventListener('mousemove',function(e){
                IMG.style.left=e.clientX+'px'
            IMG.style.top=e.clientY+'px'
            console.log("横坐标："+e.clientX)
            console.log("纵坐标："+e.clientY)
            })
            
        

    </script>
</body>
</html>